<template>
  <view class="container">
   <!-- <view class="search-box">
      <view class="title">筛查进度：</view>
      <u--input
        placeholder="请选择筛查进度"
        border="surround"
        clearable
        disabled
        v-model="queryParams.result1"
      ></u--input>
      <u-button
        style="width: 20%;"
        type="success"
        @tap="getJd"
        text="请选择"
      ></u-button>
    </view> -->
    <view class="search-box">
      <view class="title">筛查年度：</view>
      <picker
        mode="date"
        :value="queryParams.planYear"
        fields="year"
        @change="bindDateChange"
      >
        <view style="padding: 0 40rpx;" class="uni-input">{{ date }}年</view>
      </picker>
    </view>

    <view class="search-box">
      <view class="title">筛查季度：</view>
      <u--input
        placeholder="请选择筛查季度"
        border="surround"
        clearable
        disabled
        v-model="queryParams.planQuarter2"
      ></u--input>
      <u-button
        style="width: 20%;"
        type="success"
        @tap="getScjd"
        text="请选择"
      ></u-button>
    </view>
	
	<view class="search-box">
	  <view class="title">学校信息：</view>
	  <u--input
	    placeholder="请选择学校信息"
	    border="surround"
	    clearable
	    disabled
	    v-model="queryParams.queryXxParms1"
	  ></u--input>
	  <u-button
	    style="width: 20%;"
	    type="success"
	    @tap="getSC"
	    text="请选择"
	  ></u-button>
	</view>

    <view
      @tap="toCj(item)"
      class="item-box"
      v-for="(item, index) in jhList"
      :key="index"
    >
      <view class="item-name">{{ item.schooName }}</view>
      <view class="item-detail">年级：{{ item.gradeName }}</view>
      <view class="item-detail">班级：{{ item.className }}</view>
      <view class="item-detail">筛查年度：{{ item.planYear }}</view>
      <view class="item-detail">筛查季度：{{ item.planQuarter }}</view>
      <view class="item-detail">已筛查:{{ item.tjQty3 }}人</view>
      <view class="item-detail">未筛查:{{ item.tjQty2 }}人</view>
      <view
        @tap.stop="updateItem(item)"
        class="update-button"
      >
        更新
      </view>
    </view>

    <u-picker
      :show="scjdshow"
      :columns="jdList"
      @cancel="scjdshow = false"
      @confirm="confirmJD"
      keyName="label"
    ></u-picker>
    <u-picker
      @cancel="jdshow = false"
      @confirm="jdconfirm"
      :show="jdshow"
      :columns="jdcolumns"
      keyName="label"
    ></u-picker>
  </view>
</template>

<script>
import { getDicts } from "@/api/system/dict/data.js";
import {
  mainListScreenPlanInfo,
  getScreenPlanInfo,
  delScreenPlanInfo,
  generateScreenPlanInfo,
  reNewScreenPlanInfo
} from "@/api/files/screenPlanInfo";

export default {
  data() {
    return {
      date: "2025", // 默认选中的日期
      scjdshow: false,
      jdshow: false,
      jdcolumns: [
        [
          {
            label: "未完成",
            id: 0
          },
          {
            label: "已完成",
            id: 1
          }
        ]
      ],
      jdList: [],
      itemData: {},
      jhList: [],
      queryParams: {
        pageNum: 1,
        pageSize: 100,
        planYear: "2025",
		planQuarter2:"四季度",
		planQuarter:4
      }
    };
  },
  onShow() {
    let pages = getCurrentPages();
    if (pages[pages.length - 1].$vm.deptData) {
      this.itemData = pages[pages.length - 1].$vm.deptData;
      this.queryParams.queryXxParms = this.itemData.id;
      this.queryParams.queryXxParms1 = this.itemData.label;
      this.getList();
    }
  },
  onLoad(e) {
    //this.getList();
    getDicts("plan_quarter").then((res) => {
      let arr = [];
      var data = res.data;
      for (let i = 0; i < data.length; i++) {
        arr[i] = {
          label: data[i].dictLabel,
          id: data[i].dictValue
        };
      }
      this.jdList = [arr];
    });
  },
  methods: {
    updateItem(item) {
      reNewScreenPlanInfo(item).then((res) => {
        this.getList();
      });
    },
    bindDateChange(e) {
      this.date = e.target.value.substr(0, 4);
      this.queryParams.planYear = e.target.value.substr(0, 4);
      this.getList();
    },
    confirmJD(e) {
      this.queryParams.planQuarter2 = e.value[0].label;
      this.queryParams.planQuarter = e.value[0].id;
      this.scjdshow = false;
      this.getList();
    },
    jdconfirm(e) {
      this.queryParams.result1 = e.value[0].label;
      this.queryParams.result = e.value[0].id;
      this.jdshow = false;
      this.getList();
    },
    getJd() {
      this.jdshow = true;
    },
    getScjd() {
      this.scjdshow = true;
    },
    getSC() {
      uni.navigateTo({
        url: "/pages/common/deptItem"
      });
    },
    getList() {
      mainListScreenPlanInfo(this.queryParams).then((res) => {
        this.jhList = res.rows;
      });
    },
    toCj(e) {
      uni.navigateTo({
        url: `/pages/slcj/index?code=${e.planNo}`
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.container {
  background-color: #F2F2F2;
  min-height: 100vh;
  padding: 20rpx;
}
.search-box {
  display: flex;
  align-items: center;
  margin-bottom: 20rpx;
  .title {
    margin-right: 10rpx;
	font-size: 30rpx;
  }
}
.item-box {
  width: 92%;
  margin: 0 auto;
  background-color: #fff;
  border-radius: 20rpx;
  margin-bottom: 20rpx;
  padding: 20rpx;
  position: relative;
  .item-name {
    font-size: 34rpx;
    font-weight: 600;
  }
  .item-detail {
    font-size: 28rpx;
    color: #333;
    margin-top: 10rpx;
  }
  .update-button {
    position: absolute;
    right: 10rpx;
    bottom: 10rpx;
    background-color: #67e3cb;
    padding: 12rpx 25rpx;
    border-radius: 10rpx;
    color: #fff;
  }
}
</style>